<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use App\Models\Video;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class CallBackController extends Controller
{
    public function video(Request $request){
        $input = $request->input();
        Log::info(json_encode($input));
        $result = $input['ProcedureStateChangeEvent'];
        $video = Video::where('file_id',$result['FileId'])->first();
        $video->duration = $result['MediaProcessResultSet'][0]['TranscodeTask']['Output']['Duration'];
        $video->size = $result['MediaProcessResultSet'][0]['TranscodeTask']['Output']['Size'];
        $video->play_url = json_encode($result['MediaProcessResultSet'][0]['TranscodeTask']['Output']);
        $video->results = json_encode($input);
        $video->save();
    }
}
